import 'package:flutter/material.dart';
import 'package:flutter_json_view/flutter_json_view.dart';

class JsonViewer extends StatelessWidget {
  const JsonViewer({
    required this.jsonObject
  });
  final Map jsonObject;

  @override
  Widget build(BuildContext context) {
    JsonViewTheme jsonViewStyle = const  JsonViewTheme(
      backgroundColor: Colors.white,
      keyStyle: TextStyle(
        color: Colors.black87,
        fontWeight: FontWeight.w600,
      ),
      doubleStyle: TextStyle(
        color: Colors.green,
      ),
      intStyle: TextStyle(
        color: Colors.green,
      ),
      stringStyle: TextStyle(
          color: Colors.blueGrey,
          height: 1.3
      ),
      boolStyle: TextStyle(
        color: Colors.deepOrange,
      ),
      closeIcon: Icon(
        Icons.arrow_drop_up,
        color: Colors.black87,
        // size: 20,
      ),
      openIcon: Icon(
        Icons.arrow_drop_down,
        color: Colors.black87,
        size: 20,
      ),
      separator: Padding(
          padding: EdgeInsets.fromLTRB(3.0, 0.0, 3.0, 0.0),
          child: Text(':',style: TextStyle(color: Colors.black87,fontSize: 15),)
      ),
    );
    return JsonView.map( Map<String, dynamic>.from(jsonObject), theme: jsonViewStyle );
  }
}
